<template>
	<view class="content">
		<!-- 顶部导航栏组件 -->
		<!-- <QSNavbar :navbarItems="navbarItems_1" backgroundColor="#ffffff"></QSNavbar> -->
		<view class="news-box">
			<!-- 新闻描述 -->
			<view class="news-remark">
				<u--text :text="newsData.remark" v-if="newsData.remark" :bold="true" size="22"></u--text>
			</view>
			<!-- 发送方和发送时间 -->
			<view class="new-item-time">
				<view class="building">
					<u--text :prefixIcon="building" :text="newsData.sender" align="left" size="20rpx"
						:iconStyle="{width:20+'rpx',height:20+'rpx'}" color="#999999" lines="1"
						v-if="newsData.sender"></u--text>
				</view>
				<view class="building">
					<u--text :text="newsData.create_at" size="20rpx" color="#999999" align="left"
						v-if="newsData.create_at"></u--text>
				</view>
				<u--text prefixIcon="bookmark" :text="newsData.num_read" size="20rpx" color="#999999" align="left"
					v-if="newsData.num_read || newsData.num_read == 0"></u--text>
			</view>
			<!-- 内容 -->
			<view class="u-content">
				<u-parse :content="newsData.content"></u-parse>
			</view>
		</view>
	</view>
</template>

<script>
	import QSNavbar from '@/components/QS-Navbar/QS-Navbar.vue';
	const index = require('@/api/index/index.js')
	export default {
		components: {
			QSNavbar
		},
		data() {
			return {
				navbarItems_1: [{
					type: 'icon',
					icon: 'back',
					layout: 'left',
					width: 15,
					doEvent: 'back',
					iconColor: '#000'
				}, {
					type: 'text',
					text: '',
					width: 70,
					weight: 'bold',
					color: '#000',
					textAlign: 'left'
				}],
				newsData: {},
				building: this.$https.assetsPath + '48c89be73bd5b5100d62d9e224efd88047b262fa.png',
			};
		},
		onLoad(option) {
			let that = this
			if (option.id) {
				that.getNewsDetail(option.id)
			}
		},
		methods: {
			async getNewsDetail(id) {
				let that = this
				let data = {
					weixinAppId: this.$https.weixinAppId,
					projectId: getApp().globalData.projectId,
					id: id
				}
				let result = await index.getNewsDetail(data)
				if (result.code == 1) {
					that.newsData = result.data.data
					uni.setNavigationBarTitle({
						title: result.data.data.name
					});
					// that.navbarItems_1[1].text = result.data.data.name
				}
			}
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
	}

	.new-item-time {
		display: flex;
	}

	.building {
		width: 200rpx;
	}

	.new-item-time /deep/ .u-text__value {
		margin-left: 20rpx;
		margin-right: 20rpx;
	}

	.news-box {
		padding: 26rpx;
	}

	.news-remark {
		padding-bottom: 20rpx;
	}

	.new-item-time {
		padding-bottom: 20rpx;
	}
</style>